package model

import (
	"gorm.io/gorm"
	"time"
)

type Room struct {
	Id        uint           `gorm:"column:id;type:bigint(20) UNSIGNED;primaryKey;not null;" json:"id"`
	UserId    uint           `gorm:"column:user_id;type:bigint(20) UNSIGNED;comment:创建群的用户;not null;default:0;" json:"user_id"` // 创建群的用户
	Name      string         `gorm:"column:name;type:varchar(255);comment:群名称;not null;" json:"name"`                           // 群名称
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

type RoomUser struct {
	Id         uint           `gorm:"column:id;type:bigint(20) UNSIGNED;primaryKey;not null;" json:"id"`
	RoomUserId uint           `gorm:"column:room_user_id;type:bigint(20) UNSIGNED;comment:群成员id;not null;default:0;" json:"room_user_id"` // 群成员id
	Auth       uint           `gorm:"column:auth;type:int(10) UNSIGNED;comment:权限: 1:群主 2:管理员 3:成员;not null;default:0;" json:"auth"`      // 权限: 1:群主 2:管理员 3:成员
	RoomId     uint           `gorm:"column:room_id;type:bigint(20) UNSIGNED;comment:群id;not null;default:0;" json:"room_id"`             // 群id
	Remark     string         `gorm:"column:remark;type:varchar(255);comment:成员批注;not null;" json:"remark"`                               // 成员批注
	CreatedAt  time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt  time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt  gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (Room) TableName() string {
	return "room"
}
func (RoomUser) TableName() string {
	return "room_user"
}
